Skip to content

Add support for fused Q Up-Proj GEMM/RoPE/Quant. - #3303

Open
chaseblock wants to merge 2 commits into
NVIDIA:mainfrom
chaseblock:qrope_fusion
Open

Add support for fused Q Up-Proj GEMM/RoPE/Quant.#3303
chaseblock wants to merge 2 commits into
NVIDIA:mainfrom
chaseblock:qrope_fusion

Conversation

@chaseblock

Copy link
Copy Markdown
Contributor

This PR adds support for fusing the GEMM in the Q Up Proj step of DeepseekV3 training with the following RoPE and MXFP8 quantization operations. This uses a custom kernel from cudnn_frontend, and supports both 16-bit projection and mxfp8 projection.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

This commit add support for fusing the GEMM in the Q Up Proj
step of DeepseekV3 training with the following RoPE and MXFP8
quantization operations. This uses a custom kernel from cudnn_frontend,
and supports both 16-bit projection and mxfp8 projection.
@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Aug 3, 2026
@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR introduces an exported wrapper for a cuDNN fused MLA Q up-projection, RoPE, and MXFP8 quantization operation, while extending fused attention to accept prequantized MXFP8 Q/K/V and optionally emit BF16 gradients.

  • Adds the FusedMLAQUpProjRopeQuant public API and SM100 kernel capability detection.
  • Adds split MXFP8 quantization and scale transpose/swizzle helpers.
  • Extends fused-attention layout detection and backward output handling for prequantized MXFP8 tensors.

Confidence Score: 5/5

The PR appears safe to merge based on the reviewed changes, with no concrete blocking or independently actionable non-blocking defect established.

The new MXFP8 layout transformations follow the established fast-path conventions, the BF16-gradient option is consistently forwarded through direct and checkpointed fused-attention paths, and no reachable changed-code failure remains.

Important Files Changed

Filename Overview
transformer_engine/pytorch/attention/fused_mla_q_uproj.py Adds the SM100 cuDNN wrapper, capability detection, warmup, BF16/MXFP8 projection paths, and wrapping of kernel output as an MXFP8 tensor.
transformer_engine/pytorch/attention/dot_product_attention/utils.py Adds split MXFP8 quantization and BHSD scale transpose/swizzle utilities that mirror the existing combined fast path.
transformer_engine/pytorch/attention/dot_product_attention/dot_product_attention.py Recognizes prequantized MXFP8 Q/K/V storage and forwards the new BF16-backward option through fused-attention dispatch.
transformer_engine/pytorch/attention/dot_product_attention/backends.py Adds MXFP8 scale-format metadata and allows fused-attention backward to dequantize dQ/dK/dV despite quantized inputs.
transformer_engine/pytorch/attention/init.py Exports the new fused MLA operation from the attention package.
transformer_engine/pytorch/init.py Exposes the new fused MLA operation from the top-level PyTorch API.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  X["Q low-rank activation"] --> F["Fused Q up-projection + RoPE"]
  W["BF16 or MXFP8 weight"] --> F
  C["RoPE cosine/sine"] --> F
  F --> Q["Prequantized MXFP8 Q"]
  K["K activation"] --> KV["MXFP8 quantization"]
  V["V activation"] --> KV
  Q --> S["BHSD scale transpose + swizzle"]
  KV --> S
  S --> A["cuDNN fused attention"]
  A --> B["BF16 dQ/dK/dV when requested"]
Loading

Reviews (1): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant